package com.imooc.pan.server.common.schedule;

import com.imooc.pan.schedule.ScheduleManager;
import com.imooc.pan.server.common.task.CleanExpireChunkFileTasK;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

/**
 * 定时清理过期文件分片任务触发器
 * @author hhb
 * @data 2024/6/14 22:56
 */
@Slf4j
@Component
public class CleanExpireFileChunkTaskLauncher implements CommandLineRunner {


    //每天凌晨1点
    //private final static String CRON = "1 0 0 * * ? ";

    //每隔5秒
    private final static String CRON = "0/5 * * * * ? ";

    @Autowired
    private CleanExpireChunkFileTasK cleanExpireChunkFileTasK;

    @Autowired
    private ScheduleManager scheduleManager;
    @Override
    public void run(String... args) throws Exception {
        scheduleManager.startTask(cleanExpireChunkFileTasK,CRON);
    }
}
